from docx import Document
from docx.shared import Inches

document = Document()

# 添加一个标题
document.add_heading('The role of dolphins', level=2)
# 添加一个段落
paragraph = document.add_paragraph('Lorem ipsum dolor sit amet.')
paragraph.add_run('dolor sit amet.')
# 段落缩进
paragraph_format = paragraph.paragraph_format
paragraph_format.left_indent = Inches(0.5)


document.save('new-file-name.docx')